package com.example.springmvc.service.impl;

import com.example.springmvc.mapper.UserMapper;
import com.example.springmvc.pojo.User;
import com.example.springmvc.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("userService")
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public List<User> queryUserList() {
        return userMapper.selectByExample(null);
    }

    @Override
    public User queryUserById(int id) {
        return userMapper.selectByPrimaryKey(id);
    }

    @Override
    public void updateUserById(User user) {
        userMapper.updateByPrimaryKeySelective(user);
    }

    @Override
    public User queryUserByusername(String username) {
        return userMapper.selectByName(username);
    }
}
